/*
 * 
 * 
 * 
 */
package com.hboxs.asl.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * Entity - 充值
 */
@Entity
@Table(name = "xx_core_point_trade")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_core_point_trade_sequence")
public class CorePointTrade extends BaseEntity {

    private static final long serialVersionUID = -1209590619136943215L;

    /**
     * 流水号
     */
    private String uuid;

    /**
     * 积分中心sn
     */
    private String sn;

    /**
     * 会员
     */
    private Member member;

    /**
     * 积分
     */
    private BigDecimal point;

    /**
     * 流水类型
     */
    public enum Type {

        //导出积分
        importPoint,

        //下载积分
        exportPoint;

        private static Map<String, CorePointTrade.Type> map = new HashMap<>();

        static {
            map.put("导出积分", importPoint);
            map.put("下载积分", exportPoint);
        }

        @JsonCreator
        public static CorePointTrade.Type forValue(String value) {
            return map.get(value);
        }

        @JsonValue
        public String toValue() {
            for (Map.Entry<String, CorePointTrade.Type> entry : map.entrySet()) {
                if (entry.getValue() == this) {
                    return entry.getKey();
                }
            }

            return "";
        }
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    private Type type;

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Member getMember() {
        return member;
    }

    public void setMember(Member member) {
        this.member = member;
    }

    public BigDecimal getPoint() {
        return point;
    }

    public void setPoint(BigDecimal point) {
        this.point = point;
    }
}